using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using CasaBella.Entities;

namespace CasaBella.Repository.Mapping
{
    public class COMPRAMap : EntityTypeConfiguration<COMPRA>
    {
        public COMPRAMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.NGuiaRemision)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("COMPRA");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Fecha).HasColumnName("Fecha");
            this.Property(t => t.NGuiaRemision).HasColumnName("NGuiaRemision");
            this.Property(t => t.Total).HasColumnName("Total");
            this.Property(t => t.IdProveedor).HasColumnName("IdProveedor");

            // Relationships
            this.HasRequired(t => t.PROVEEDOR)
                .WithMany(t => t.COMPRAs)
                .HasForeignKey(d => d.IdProveedor);

        }
    }
}
